cc.Class({
    extends: cc.Component,

    properties: {
        ipAccount: cc.EditBox,
        ipPassword: cc.EditBox,
        ipName: cc.EditBox,
        tgpSex: cc.ToggleGroup,
        tgMale: cc.Toggle,
        tgFemale: cc.Toggle,
    },

    // use this for initialization
    onLoad: function () {
        window.ui_register = this;
    },

    onClickBack: function () {
        uiMgr.close("ui_register");
        uiMgr.open("ui_login");
    },

    onClickConfirm: function () {

        var that = this;

        this.account = this.ipAccount.string;
        this.password = this.ipPassword.string;
        this.name = this.ipName.string;
        this.sex = this.tgMale.isChecked ? 1 : 2;

        pomelo.request("connector.authHandler.register",
            { account: that.account, password: that.password, name: that.name, sex: that.sex },
            function (data) {
                cc.log("pomelo.return[connector.authHandler.register]: data is ", data);
                if (data.code == 200) {
                    uiMgr.close("ui_register");
                    uiMgr.open("ui_login");
                } else {
                }
            });
    }
});
